<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
	 <%@ include file="/common/meta.jsp" %>
 	 <%@ include file="/common/import.jsp"%>
    <base href="<%=basePath%>">
    
    <title>会员列表页面</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
	<style type="text/css">
		#userRegTable,#editTable
		  {
		  font-family:"Trebuchet MS", Arial, Helvetica, sans-serif;
		  width:50%;
		  border-collapse:collapse;
		  }
		
		#userRegTable td,#editTable td, #customers th,#editTable th 
		  {
		  font-size:1em;
		  border:1px solid #98bf21;
		  padding:3px 7px 2px 7px;
		  }
		
		#userRegTable th,#editTable th
		  {
		  font-size:1.1em;
		  text-align:left;
		  padding-top:5px;
		  padding-bottom:4px;
		  background-color:#A7C942;
		  color:#ffffff;
		  }
		
		 .alt
		  {
		  color:#000000;
		  background-color:#EAF2D3;
		  }
	</style>
	
	<script type="text/javascript">
		$(function(){
			//控制div显示和隐藏
			$('#tab_search').panel({
				iconCls : "icon-search",//图标
				collapsible : true,//是否可折叠面板
				collapsed : true,//是否初始化折叠面板
				title : "查询会员"//标题
			});
			$('#dataCateList').datagrid({
				title:'会员列表',
				iconCls:'icon-ok',
				url:"${ctx}/admin/member/queryMemberList.action",
				nowrap: false,
				striped: true,
				collapsible:false,				
				fitColumns: true,
				pagination:true,
				singleSelect:true,
				rownumbers:true,
				remoteSort: false,
				pageList:[15,20,30,50],
				idField:'memberId',
				columns:[[
					{field:'memberEname',title:'会员名称',width:50},
					{field:'memberCname',title:'会员全称',width:70},
					{field:'shortName',title:'真实姓名',width:45},
					{field:'createTime',title:'申请时间',width:55},
					{field:'memberRoles',title:'会员类型',width:30,
						formatter:function(value){
							if( value == '1'){return '普通会员';}
							else if(value == '2'){return '专家';}
							else{ return '未定义';}
						}
					},
				{field:'auditStatus',title:'状态',width:40,
						formatter:function(value){
							if(value=='10'){
								return '<font color=blue>审核中</font>';
							}else if(value == '0'){
								return '<font color=blue>暂存</font>';
							}else if(value == '91'){
								return '<font color=blue>审核通过</font>';
							}else if(value == '90'){
								return '<font color=blue>审核不通过</font>';
							}else{ 
								return '<font color=red>未知状态</font>';
							}
						}
					},
					{field:'op',title:'操作',width:80,
						formatter : function(value, member) {
							var info = "";
							info += "<a href=\"javascript:void(0)\" onclick=\"view('view','"
								+ member.memberId+"','"+ member.memberType + "','"+ member.memberRoles
								+ "')\" style=\"color: green\">查看</a>  ";
							if(member.auditStatus=='10'){
								info += " | <a href=\"javascript:void(0)\" onclick=\"view('audit','"
									+ member.memberId+"','"+ member.memberType + "','"+ member.memberRoles
									+ "')\" style=\"color: blue\">会员审核</a>  ";
								 
							}
							if(member.auditStatus=='10' || member.auditStatus=='90'){
								info += " | <a href=\"javascript:void(0)\" onclick=\"deleteCate('"
									+ member.memberId
									+ "')\" style=\"color: red\">删除</a>";
							}
<%--								info += "<a href=\"javascript:void(0)\" onclick=\"editCate('"--%>
<%--										+ member.memberId--%>
<%--										+ "')\" style=\"color: blue\" >修改</a> ";--%>
								
<%--								var memberLevel = member.memberLevel;--%>
<%--								if(memberLevel==1){--%>
<%--									  info += "<a href=\"javascript:void(0)\" onclick=\"identifyApply('"--%>
<%--											+ member.memberId--%>
<%--											+ "')\" style=\"color: blue\" >认证申请</a> ";--%>
<%--								}--%>
											
							return info;
						}
					}
				]]<%--,
				toolbar:[{
					text:'增加',
					iconCls:'icon-add',
					handler:function(){
						saveCate();
					}
				},'-',{
					text:'刷新',
					iconCls:'icon-reload',
					handler:function(){
						$('#dataCateList').datagrid('reload');
					}
				}
				]--%>
			});		
		});
		
		function view(flag,memberId,memberType,memberRoles){
			if(null == memberId || undefined == memberId){
				alert("选择的会员无效");
			}
		   window.location.href = "${ctx}/sendPage/member/view/member-view?flag="+flag+"&memberId=" + memberId+"&memberType="+memberType+"&memberRoles="+memberRoles;
		}	
		
	  //取得数据
	  function getSelected(){
	  	var rec = $('#dataCateList').datagrid('getSelected');
	  	if(rec){
	  		return rec;
	  	}else{
	  		$.messager.alert('提示',"请选择需要操作记录!", 'info');
	  		return null;
	  	}
	  }
		
		// 查找
		function searchCate(){
	        var queryParams = $('#dataCateList').datagrid('options').queryParams;	    
	       	var opt = $('#dataCateList').datagrid('options'); 
	        $('#dataCateList').datagrid('options').pageNumber=1;
	        queryParams["memberEname"] = $('#memberEname').val();
			queryParams["memberCname"] = $('#memberCname').val();
	        $('#dataCateList').datagrid('reload');
	        
	        var page = $('#dataCateList').datagrid('getPager');
			page.pagination({pageNumber:1,pageSize:opt.pageSize});
		}
		
		// 进入增加页面
		function saveCate(){
			window.location.href = "${ctx}/sendPage/member/member-save";
		}

		// 点击取消按钮，关闭添加窗口
		function colseAdd(){
			$('#saveDiv').window('close');
		}
		
		// 刷新列表
		function cateReload(){
			$('#dataCateList').datagrid('reload');
		}
		
		 //关闭win
		 function closeWin(){
		 	$('#saveDiv').window('close');	
		 }
		 
		 //关闭win
		 function closeVisitWin(){
		 	$('#saveVisitRecordDiv').window('close');	
		 }
		 
		 //关闭win
		 function closeClientManagerWin(){
		 	$('#saveClientManagerDiv').window('close');	
		 }
		 
		// 判断是否选中一条记录
		function getSelected(){
			var selected = $('#dataCateList').datagrid('getSelected');
			if (selected){
				return selected;
			}else{
				$.messager.alert('提示', '请选择要操作的数据', 'info');
			}
		}
		
		// 进入修改页面
		function editCate(memberId){
			window.location.href = "${ctx}/sendPage/member/member-save?memberId=" + memberId;
		}
		
		//会员认证申请
		function identifyApply(memberId){
			window.location.href = "${ctx}/sendPage/member/member-identify-apply?memberId=" + memberId;
		}
		
		//删除，物理删除
		function deleteCate(memberId){					
			//var node = getSelected();	
			//if(node){
		    	$.messager.confirm('确认','您确定要删除，删除后不可恢复 ？',function(r){
		        	if(r){
						$.ajax({
							type: "post",
							url: "${ctx}/admin/member/delete.action?memberId=" + memberId,
							dataType: "json",
							success: function(data){
								var flag = data.flag;
							    var msg = data.msg;
	    						if(flag){
									$.messager.alert('结果', '操作成功', 'info');	
									$('#dataCateList').datagrid('reload');
	    						}else{
	    							$.messager.alert('结果', '操作失败，请重试', 'error');	
	    						}
							},
							error:function(messg)  { 
					       	    $.messager.alert('错误提示', '操作失败:'+messg.responseText, 'error');
					       } 
						});
		          	}
		       });		             		
		   // }	
		}
		
	</script>

  </head>
  <body>
  	 <!-- 查询窗口 -->
	<!-- 查询窗口 -->
  	 	<div id="tab_search">

		<table class="datagrid-body" >
			<tr>	
				<td class="datagrid-header">用户账号：</td>
				<td><input type="text" id="memberEname" name="memberEname" size="30" value="" /></td>
			</tr>
			
			<tr >
				<td class="datagrid-header">用户名称：</td>
				<td><input type="text" id="memberCname" name="memberCname" size="30" value="" /></td>
			</tr>

		
			<tr>	
				<td class="datagrid-header"></td>
				<td><a href="javascript:void(0);" class="easyui-linkbutton" iconCls="icon-search" onClick="searchCate();">查找</a></td>	
			</tr>
		</table>

	</div>
    
     <!-- 修改窗口 -->
 	 <div id="saveDiv" class="easyui-window" title="修改会员" style="padding:5px;width: 700px;height:450px;"
    	iconCls="icon-search" closed="true" maximizable="false" minimizable="false" collapsible="false">
   		<iframe frameborder="0"  id="saveFrame" height="100%" width="100%" scrolling="auto" frameborder="0" ></iframe>
     </div>
     <table id="dataCateList"></table>
    

  </body>
</html>
